import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEField } from '../dataentity/defield/ipsdefield';
import { IPSSysEAIDEField } from './ipssys-eaidefield';
import { IPSSysEAIElement } from './ipssys-eaielement';
import { IPSSysEAIElementAttr } from './ipssys-eaielement-attr';
import { IPSSysEAIElementRE } from './ipssys-eaielement-re';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysEAIDEFieldImpl extends PSModelObjectImpl implements IPSSysEAIDEField {
  get codeName(): string {
    return this.M.codeName;
  }

  get dstType(): 'ATTRIBUTE' | 'ELEMENT' {
    return this.M.dstType;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get fieldTag(): string {
    return this.M.fieldTag;
  }

  get fieldTag2(): string {
    return this.M.fieldTag2;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdefield = ipsdataentity.findPSDEField(value);
    }
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定实体属性');
    }
    return value;
  }

  protected pssyseaielementattr: IPSSysEAIElementAttr | null = null;

  getPSSysEAIElementAttr(): IPSSysEAIElementAttr | null {
    if (this.pssyseaielementattr != null) return this.pssyseaielementattr;
    const value = this.M.getPSSysEAIElementAttr;
    if (value == null) {
      return null;
    }
    const ipssyseaielement = this.getParentPSModelObject('eai.IPSSysEAIElement') as IPSSysEAIElement;
    if (ipssyseaielement != null) {
      this.pssyseaielementattr = ipssyseaielement.findPSSysEAIElementAttr(value);
    }
    return this.pssyseaielementattr;
  }

  get psSysEAIElementAttr(): IPSSysEAIElementAttr | null {
    return this.getPSSysEAIElementAttr();
  }

  getPSSysEAIElementAttrMust(): IPSSysEAIElementAttr {
    const value = this.getPSSysEAIElementAttr();
    if (value == null) {
      throw new Error('未指定集成元素属性');
    }
    return value;
  }

  protected pssyseaielementre: IPSSysEAIElementRE | null = null;

  getPSSysEAIElementRE(): IPSSysEAIElementRE | null {
    if (this.pssyseaielementre != null) return this.pssyseaielementre;
    const value = this.M.getPSSysEAIElementRE;
    if (value == null) {
      return null;
    }
    const ipssyseaielement = this.getParentPSModelObject('eai.IPSSysEAIElement') as IPSSysEAIElement;
    if (ipssyseaielement != null) {
      this.pssyseaielementre = ipssyseaielement.findPSSysEAIElementRE(value);
    }
    return this.pssyseaielementre;
  }

  get psSysEAIElementRE(): IPSSysEAIElementRE | null {
    return this.getPSSysEAIElementRE();
  }

  getPSSysEAIElementREMust(): IPSSysEAIElementRE {
    const value = this.getPSSysEAIElementRE();
    if (value == null) {
      throw new Error('未指定集成元素引用属性');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysEAIDEFieldImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'eai.IPSEAIDEField' || cls == 'eai.IPSSysEAIDEField') return true;
    return super.instanceof(cls);
  }
}
